package cn.iocoder.devlop.module.annual.report.supbaseinfo.controller.app;

import cn.iocoder.devlop.framework.common.pojo.CommonResult;
import cn.iocoder.devlop.module.annual.report.supbaseinfo.controller.vo.SupBaseinfoOverwriteVO;
import cn.iocoder.devlop.module.annual.report.supbaseinfo.controller.vo.SupBaseinfoRespVO;
import cn.iocoder.devlop.module.annual.report.supbaseinfo.convert.SupBaseinfoConvert;
import cn.iocoder.devlop.module.annual.report.supbaseinfo.dal.dataobject.SupBaseinfoDO;
import cn.iocoder.devlop.module.annual.report.supbaseinfo.service.SupBaseinfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.devlop.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 年报基本信息补充")
@RestController
@RequestMapping("/annual/report/sup-baseinfo")
@Validated
public class AppSupBaseinfoController {

    @Resource
    private SupBaseinfoService supBaseinfoService;

    @GetMapping("/list")
    @Operation(summary = "获得年报基本信息补充")
    public CommonResult<List<SupBaseinfoRespVO>> getSupBaseinfoList(@RequestParam("regno") String regno, @RequestParam("ancheyear") String ancheyear) {
        List<SupBaseinfoDO> list = supBaseinfoService.getSupBaseinfoList(regno, ancheyear);
        return success(SupBaseinfoConvert.INSTANCE.convertList(list));
    }

    @PutMapping("/overwrite")
    @Operation(summary = "覆盖更新年报基本信息补充")
    public CommonResult<Boolean> overwriteSupBaseinfo(@Valid @RequestBody SupBaseinfoOverwriteVO updateReqVO) {
        supBaseinfoService.overwriteSupBaseinfo(updateReqVO);
        return success(true);
    }

}
